#!/usr/bin/env node
var timer1;
var timer2;
var timer2Count = 0; 

function timerTask() {
  console.log('Timer task');
}

console.log('Timer 1');
timer1 = setTimeout(function() {
  console.log('Timer 1 ended, starting Timer 2');
  clearInterval(timer1); 

  timer2 = setInterval(function() {
    timerTask(); 
    timer2Count++; 
    if (timer2Count === 5) {
      console.log('Timer 2 ended');
      clearInterval(timer2); 
      process.exit();
    }
  }, 500);
}, 5000); 